import os
import shutil

import pytest

from Common.dir_config import *
from Common.logger import Logger
from Common.dir_config import ConfigHandler
from util.noticeUtils.dingtalkControl import DingTalkSendMsg

def run():
    import warnings
    warnings.filterwarnings('ignore')
    if os.path.exists(ConfigHandler.report_dir):
        shutil.rmtree(path=ConfigHandler.report_dir)
    if os.path.exists(ConfigHandler.screenshot_dir):
        shutil.rmtree(path=ConfigHandler.screenshot_dir)
        os.mkdir(ConfigHandler.screenshot_dir)
    Logger.info("""web自动化开始""")
    pytest.main([r"D:\zhcx-erp-web-autotest\TestCases\sales_management_page\wish_sales_management_page\test_001.py","--clean-alluredir"])
    # pytest.main(["./TestCases/","--clean-alluredir"])
    result_path = ConfigHandler.report_dir+ "data"
    report_path = ConfigHandler.report_dir+ "html"
    to_report_comline =f"allure generate {result_path} -o {report_path} --clean"
    os.system(to_report_comline)
    # DingTalkSendMsg().send_ding_notification()
    # os.system(f"allure serve {result_path} -h 127.0.0.1 -p 9999")
    Logger.info("web自动化结束")



if __name__ == '__main__':
    run()